extends ../layout

block content
  h2.page-header 添加文章

  if errors && errors.length
    div.errors
      each error in errors
        p.alert.alert-danger= error.msg

  form.vertical-form(method="post", action=action)
    div.form-group
      label(for="title") 标题
      input.form-control.input-lg(name="title", placeholder="请输入标题...", required="true", value=post.title)

    div.form-group
      label(for="category") 分类
      select.form-control.input-lg(name="category", required="true")
        option(value="", selected=true) - 选择分类 -
        each category in categories
          option(value=category._id, selected=(category._id.toString() === post.category._id.toString()))= category.name

    div.form-group
      label(for="content") 内容
      textarea#js-post-content.form-control(name="content", required="true")= post.content

    button.btn.btn-lg.btn-info(type="submit")= post ? "保存修改" : "发布文章"

block scripts
  script(src="/js/ckeditor/ckeditor.js")  //不能有分号
  script(src="/js/admin/post.js")
